package com.t.bricks.bussiness.db.dao.waitnote.impl;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.t.bricks.bussiness.db.dao.waitnote.WaitNoteDao;
import com.t.bricks.bussiness.db.entity.waitnote.WaitNote;
import com.t.bricks.bussiness.db.entity.waitnote.WaitNoteSimpl;
import com.t.bricks.bussiness.db.mapper.waitnote.WaitNoteMapper;
import com.t.bricks.model.Log;
import com.t.bricks.model.MsgEmity;

@Repository
public class WaitNoteDaoImpl implements WaitNoteDao<WaitNote> {
	
	@Autowired
	private WaitNoteMapper waitNoteMapper;
	
	/**
	 * 查找待通知的信息
	 * @param sOwnerId
	 * @param dEndDateSt
	 * @param dEndDateEd
	 * @return
	 */
	@Override
	public MsgEmity findByNotice(String sOwnerId, Date dEndDateSt, Date dEndDateEd) {
		List<WaitNoteSimpl> list = null;
		try {
			list = waitNoteMapper.findByNotice(sOwnerId, dEndDateSt, dEndDateEd, 2);
			if (null == list) {
				return new MsgEmity(false, "数据不存在！", 7001);
			}
			if (list.size() < 1) {
				return new MsgEmity(true, "查询成功，但没有数据！", list);
			}
		} catch (Exception e) {
			Log.error("查询发生异常:", e.getMessage());
			return new MsgEmity(false, "查询失败！", 7002);
		}
		
		return new MsgEmity(true, "查询成功！", list);
	}

}
